package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	printMultiplicationTable()
	arr := [20]uint{}
	for i := 0; i < 20; i++ {
		value := random(20)
		arr[i] = value
		fmt.Printf("value: %v\n", value)
	}
	s, p := computed(arr)
	fmt.Printf("第单数个累加和：%d,第偶数个累乘积：%d\n", s, p)

	for i := 1; i <= 100; i++ {
		fmt.Printf("%+v ", fibonacci(uint(i)))
	}

}

func printMultiplicationTable() {
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%[1]d*%-[2]d ", i, j, i*j)

		}
		fmt.Println()
	}
}
func random(maxValue uint) uint {

	rand.NewSource(time.Now().UnixNano())
	return uint(rand.Intn(int(maxValue) + 1))
}
func computed(arr [20]uint) (uint, uint) {
	var sum uint = 0
	var product uint = 1
	if len(arr) == 0 {
		return 0, 0
	}
	for i := 0; i < len(arr); i++ {
		if (i+1)%2 == 0 {
			product *= arr[i]
		} else {
			sum += arr[i]
		}
	}
	return sum, product
}
func fibonacci(s uint) uint {
	if s == 0 || s == 1 {
		return s
	} else {
		return fibonacci(s-1) + fibonacci(s-2)

	}
}


// 批改意见
// 1. 乘法口诀表里输出时少了最后一个元素的输出格式化字符串；
// 2. 斐波那契数列要求输出数列中100以内的值，而不是输出数列中第100个值